package com.gf.user.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.gf.common.util.StrArrayHelper;
import com.gf.user.model.IdolFan;

public class IdolFanMapper implements RowMapper<IdolFan> {

	private final static String COLUME_ID = "id";
	private final static String COLUME_USERID = "userId";
	private final static String COLUME_USERNAME = "userName";
	private final static String COLUME_IDOLIDS = "idolIds";
	private final static String COLUME_FANIDS = "fanIds";
	private final static String COLUME_CREATETIME = "createtime";

	private static final IdolFanMapper mapper = new IdolFanMapper();

	public static IdolFanMapper getMapper() {
		return mapper;
	}

	/**
	 * 关注和粉丝各用'-'分开<br>
	 * 数字表示ID<br>
	 * 关注: 2-4-34 <br>
	 * 粉丝: 5-3-1
	 */
	@Override
	public IdolFan mapRow(ResultSet set, int row) throws SQLException {
		IdolFan idolFan = new IdolFan();

		idolFan.setId(set.getLong(COLUME_ID));
		idolFan.setUserId(set.getLong(COLUME_USERID));
		idolFan.setUserName(set.getString(COLUME_USERNAME));
		idolFan.setCreatetime(set.getTimestamp(COLUME_CREATETIME));
		idolFan.setIdolIds(StrArrayHelper.strToArray1(set.getString(COLUME_IDOLIDS), "-"));
		idolFan.setFanIds(StrArrayHelper.strToArray1(set.getString(COLUME_FANIDS), "-"));
		
		return idolFan;
	}
	
}
